package views
{
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.media.Video;
	import flash.net.NetStream;
	import flash.text.TextField;
	
	public class StreamVideo extends Sprite
	{
		private var video_stream:Video;
		private var loading:TextField = new TextField();
		private var size:Point;
		public function StreamVideo(w:Number = 320,h:Number = 240)
		{
			super();
			size = new Point(w,h);
			loading.selectable = false;
			loading.text = "loading...";
			loading.textColor = 0xFFFFFF;
			loading.width = 320;
			loading.height = 240;
		}
		public function playStream(netStream:NetStream):void{
			addChild(loading);
			video_stream = new Video(size.x,size.y);
			video_stream.smoothing = true;
			video_stream.attachNetStream(netStream);
			addChild(video_stream);
		}
		public function stopStream():void{
			if(video_stream){
				video_stream.attachNetStream(null);
				removeChild(video_stream);
				video_stream = null;
				removeChild(loading);
			}
		}
		public function resize(w:Number,h:Number):void{
			if(video_stream){
				video_stream.width = w;
				video_stream.height = h;
			}
			size = new Point(w,h);
		}
	}
}